package org.example.messageWall;

/**
 * 留言板
 */

import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/MessageWallController")
public class MessageWallController {
    @RequestMapping(path = "/getList",method = RequestMethod.GET)
    public List<String> getList(String info){
        //使用 List 来保存留言板信息
        List<String> list = new ArrayList<>();
        list.add(info);
        return list;
    }

    //提交信息给留言板
    @RequestMapping("/publish")
    public boolean publish(MessageInfo messageinfo) {
        System.out.println(messageinfo);
        if (StringUtils.hasLength(messageinfo.getFrom())
                && StringUtils.hasLength(messageinfo.getTo())
                && StringUtils.hasLength(messageinfo.getMessage())) {
            getList(messageinfo.getMessage());
            return true;
        }
        return false;
    }
}
